package com.ks.core.framework.cpsupload.demos.resp;

import java.util.Map;

// 抽象支付响应适配器
public abstract class AbstractResponseAdapter implements ResponseComponent {
    protected final String channelName;
    protected final Map<String, Object> rawData;
    
    public AbstractResponseAdapter(String channelName, Map<String, Object> rawData) {
        this.channelName = channelName;
        this.rawData = rawData;
    }

    // 公共的业务数据提取方法
    protected Double extractAmount(String amountKey) {
//        Object amount = rawData.get(amountKey);
//        if (amount instanceof Double) return (Double) amount;
//        if (amount instanceof Integer) return ((Integer) amount).doubleValue();
//        if (amount instanceof String) {
//            try {
//                return Double.parseDouble((String) amount);
//            } catch (NumberFormatException e) {
//                return 0.0;
//            }
//        }
        return 0.0;
    }
}